Often, data processing applications require storage and manipulation of irrational numbers, which are defined to be numbers which can not be expressed as a ratio of two integers. Examples include pi (.pi.), the base of the natural logarithm l, and the square root of most integers, such as the square root of 2 (.sqroot.2). These numbers are approximated as 3.14159 . . . , 2.71828 . . . , and 1.414 . . . , respectively. Irrational numbers require an infinite number of digits for precise representation.
In data processing applications, irrational numbers such as these must be approximated when storing or operating. In a data processing system, all numerical values are stored as multi-bit binary data. The number of bits by which a number can be stored is generally fixed at a number such as 8 bits, 32 bits or 64 bits. Integer values can be stored directly, while non-integer real numbers such as 1.414 must be stored as an integer part and a fractional part. A real number can be stored precisely if the value of the real number is small enough or if the fractional portion, the digits to the right of the decimal point, is small enough to be represented by the number of bits available. Irrational numbers, which have an infinite number of digits if represented as a real number, can never be stored precisely but must be truncated to a storable size.
Algebraic manipulations and storage of irrational numbers have heretofore been accomplished by approximating an irrational number with the maximum number of bits available, and storing and manipulating the approximation. However, this necessarily results in truncation error, and the error is compounded with each operation subsequent to the approximation in the form of rounding error. Each addition, multiplication or other mathematical or logical operation on the data results in rounding error. After many such operations, the error may become unacceptable.
Accordingly, there is a need in the art for an improved method of storing and manipulating data in a data processing system which maximizes the accuracy of representation of irrational numbers such as the square root of 2 (.sqroot.2).